<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .slider{
            width: 500px;
            height: 100px;
            border: 1px solid #ccc;
            margin: 100px auto;
            position: relative;
            overflow: hidden;
        }
        .slider ul{
            width: 1000px;
            height: 100px;
            list-style-type: none;
            position: absolute;
            left: 0;
        }
        .slider ul li{
            width: 90px;
            height: 90px;
            background: purple;
            text-align: center;
            line-height: 90px;
            color: #fff;
            font-size: 30px;
            float: left;
            margin: 5px;
        }
    </style>
</head>
<body>
<input type="button" value="向左移动" class="btnLeft">
<input type="button" value="向右移动" class="btnRight">
<div class="slider">
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
</div>
</body>
</html>
    <script src="js/jquery-1.10.1.js"></script>
    <script>
        $(function () {
            var tags =  $(".slider ul").html();
            $(".slider ul").html(tags + tags);
            var left = 0;
            var result = 2;
            var timer = null;
            function speed() {
                left = left - result;
                if(left < -500){
                    left = 0;
                }
                if(left > 0){
                    left = -500;
                }
                $(".slider ul").css({
                    "left" : left
                })
            }
            timer = setInterval(speed,30)
            $(".btnLeft").click(function () {
                clearInterval(timer);
                result = 2;
                timer = setInterval(speed,30);
            });
            $(".btnRight").click(function () {
                result = -2;
            })

            $(".slider").hover(function () {
                clearInterval(timer);
            },function () {
                timer = setInterval(speed,30);
            })
        })
    </script>
